package Jop;

import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

public class CleanJob3 {
    public static String resultToString(JSONArray jobdata) throws JSONException {
        String jobResultData = "";
        for (int i = 0; i < jobdata.length(); i++) {
            String everyData = jobdata.get(i).toString();
            JSONObject everyDataJson = new JSONObject(everyData);
            String company = everyDataJson.getString("company");
            String salary = everyDataJson.getString("salary");
            String positionAdvantage = everyDataJson.getString("positionAdvantage");
            JSONArray companyLabelList = everyDataJson.getJSONArray("companyLabelList");
            JSONArray skillLables = everyDataJson.getJSONArray("skillLables");
            String salaryNew = CleanJob.deleteString(salary, 'k');
            String welfare = CleanJob1.mergeString(positionAdvantage, companyLabelList);
            String kill = CleanJob2.killResult(skillLables);
            if (i == jobdata.length() - 1) {
                jobResultData = jobResultData + company + ","
                        + salaryNew + "," + welfare + "," + kill;
            } else {
                jobResultData = jobResultData + company + ","
                        + salaryNew + "," + welfare + "," + kill + "\n";
            }
        }
        return jobResultData;
    }
}